<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>
	
    <script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    var stateValue="";
    var id="${epis.id}";
   
    $().ready(function(){
    	var  epInstoreno='${epInstoreno}';
    	if(epInstoreno==null||epInstoreno==""){
    		$("#kucun").hide();
    		document.getElementById("epActualstock").value ="0";
    		document.getElementById("epInstorenum").value ="0";
    	}
		var options = {
	  	    url:'<%=request.getContextPath() %>/equipmentParts!saveEPData.action',
	  	     beforeSubmit: function() {
	   				return checking();
	    			},
	  	    dataType:'json',
	  	    success: function(data) {
	  	      if(data.result=='success'){
				alert("添加成功");
				api.close();
				//W.refreshIt();
				//W.gridSearch();
               // window.opener.freshStoreGrid();
               // jQuery("#gridTableAdd",window.parent.document).trigger("reloadGrid");
	  	      }
	  	    }};
		var options1 = {
		  	    url:'<%=request.getContextPath() %>/equipmentParts!saveEquipmentParts.action',
		  	     beforeSubmit: function() {
		   				return checking();
		    			},
		  	    dataType:'json',
		  	    success: function(data) {
		  	      if(data.result=='success'){
					alert("添加成功");
					api.close();
					W.reload();
		  	      }
		  	    }};
	$('#saveBtn').click(function(){
		        if(epInstoreno==null||epInstoreno==""){
		        	$('#pageFrom').ajaxSubmit(options1);
		        }
		        else{
		    	  $('#pageFrom').ajaxSubmit(options);
		    	  }
 	            return false;
	 });
	$('#closeBtn').click(function(){
		//alert(jQuery("#gridTableAdd",window.parent.document));
		api.close();
	});
	
});
    
    function checking(){
        }
    function selectdept(id)
	{
		var datas = window.showModalDialog("<%=request.getContextPath() %>/resource/choose/choose_organizationIndex.jsp?temp="+Math.round(Math.random()*10000),'',"dialogWidth=900px;dialogHeight=550px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("dept_"+id).value = json1.ORG_NAME;
			 document.getElementById(id).value = json1.ORG_ID;
		}
	}
    //选择适用设备
    function selectshebei(id){
    	var datas = window.showModalDialog("<%=request.getContextPath() %>/view/equipmentparts_choose_ep.jsp?",window,"dialogWidth=490px;status:no;dialogHeight=400px");
        if(datas!=null){
   		    document.getElementById(id).value = datas.ID;
   		    document.getElementById(id+"name").value = datas.EQU_NAME;
   		    document.getElementById(id+"id").value = datas.EQU_NO      		
        }
    }
  //选择供应商
    function selectgongyingshang(id){
    	var datas = window.showModalDialog("<%=request.getContextPath() %>/view/equipmentparts_choose_gys.jsp?",window,"dialogWidth=490px;status:no;dialogHeight=400px");
        if(datas!=null){
   		    document.getElementById(id).value = datas.ID;
   		    document.getElementById(id+"name").value = datas.GYS_NAME    		
        }
    }

    
   </script>
 	<style type="text/css">
 		body{
 			background:#ffffff; background-image:url(images/);
 		}
   		html{
		    overflow-x: hidden;
			overflow-y: hidden;
		}  	
		.formTableNew textarea{border: 1px solid #999;padding: 5px;width: 760px;-moz-border-radius: 3px;border-radius: 3px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;}
   </style>
  </head>
  
  <body>
<form id="pageFrom" action="" enctype="multipart/form-data" method="post">
        <input type="hidden" id="flag" name="flag" />
  		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew">
  		   <input id="epInstoreno"  name="epInstoreno" type="hidden" value="${epInstoreno}"/>
  			<tr>
  			  <td align="right">仓库名称（部门）：</td>
  			  <td align="left">
  			  <input type="hidden" id="epStorehouse" name="epStorehouse" value="${epStorehouse}"/>
              <input type="text" style="border: 1px solid #999;padding: 5px;width: 250px;"   id="dept_epStorehouse" name="dept_epStorehouse" value="${dept_epStorehouse}" class='easyui-validatebox'  required missingMessage='必填'/>
              <img src="<%=request.getContextPath() %>/images/xh.png"  align="absmiddle"></img>
  	          <img src="<%=request.getContextPath() %>/web/images/form_icon_1.gif" style="cursor:hand; vertical-align: middle;" onclick="selectdept('epStorehouse')" />
  			  	
  			  </td>
  			  <td align="right">备件代码：</td>
  			  <td align="left">
  			    <input  type="text"  id="epCode" maxlength="50" name="epCode"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;" class='easyui-validatebox'  required missingMessage='必填' />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  </tr>
  			  <tr>
  			  <td align="right">备件名称：</td>
  			  <td align="left">
  			    <input  type="text"  id="epName" maxlength="50" name="epName"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填'/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">备件属性：</td>
  			  <td align="left">
              <select id="epProperty"  class='fselect' name="epProperty"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  >
                <option value="随机备件">随机备件</option>
                <option value="外购备件">外购备件</option>
                <option value="委外备件">委外备件</option>
                <option value="回收备件">回收备件</option>
              </select></td>
  			  </tr>
  			  <tr>
  			  <td align="right">备件等级：</td>
  			  <td align="left">
  			    <select  class='fselect'  id="epLevel" maxlength="50" name="epLevel"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  />
  			    <option value="A">A</option>
                <option value="B">B</option>
                <option value="C">C</option>
  			    </select>
  			  	
  			  </td>
  			  <td align="right">规格型号：</td>
  			  <td align="left">
  			    <input  type="text"   id="epGuige" maxlength="50" name="epGuige"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填'/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  </tr>
  			  <tr>
  			  <td align="right">备件品牌：</td>
  			  <td align="left">
  			    <input  type="text"  id="epBrand" maxlength="50" name="epBrand"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填'/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">供应商：</td>
  			  <td align="left">
  			     <input  type="text" readonly  id="epSuppliername" maxlength="50" name="epSuppliername" value="${epSuppliername}"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填'/>
  			    <input  type="hidden"  id="epSupplier" maxlength="50" name="epSupplier" value="${epSupplier}"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  />
  			  	<img src="<%=request.getContextPath()%>/images/xh.png" align="absmiddle"></img>
				<img src="<%=request.getContextPath()%>/web/images/form_icon_1.gif" style="cursor:hand; vertical-align: middle;" onclick="selectgongyingshang('epSupplier')" />	
  			    
  			  </td>
  			  </tr>
  			  <tr>
  			  <td align="right">价格(元)：</td>
  			  <td align="left">
  			    <input  type="text" id="epInstoreprice" maxlength="50" name="epInstoreprice" class="easyui-numberbox" precision="3" max="99999.999"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填,请输入数字'/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">采购周期(天)：</td>
  			  <td align="left">
  			    <input  type="text"  id="epIncycle" maxlength="50" name="epIncycle" class="easyui-numberbox"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  required missingMessage='必填,请输入数字'/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  </tr>
  			   <tr>
  			  <td align="right">最大库存：</td>
  			  <td align="left">
  			    <input  type="text"  id="epMaxstock" maxlength="50" name="epMaxstock" class="easyui-numberbox" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填,请输入数字'/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">最小库存：</td>
  			  <td align="left">
  			    <input  type="text" id="epMinstock" maxlength="50" name="epMinstock" class="easyui-numberbox" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填,请输入数字'/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  </tr>
  			   <tr id="kucun">
  			  <td align="right">实际库存：</td>
  			  <td align="left">
  			    <input  type="text"  id="epActualstock" maxlength="50" name="epActualstock" value="0"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填,请输入数字'/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">入库数量：</td>
  			  <td align="left">
  			    <input  type="text"  id="epInstorenum" maxlength="50" name="epInstorenum" class="easyui-numberbox"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填,请输入数字'/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  </tr>
  			   <tr>
  			   
  			  <td align="right">适用设备名称：</td>
  			  <td align="left">
  			   <input  type="text" readonly id="epApplicableequipmentname" maxlength="50" name="epApplicableequipmentname" value="${epApplicableequipmentname}"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  class='easyui-validatebox'  required missingMessage='必填'/>
  			    <input  type="hidden"  id="epApplicableequipment" maxlength="50" name="epApplicableequipment" value="${epApplicableequipment}"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  />
  			  	<img src="<%=request.getContextPath()%>/images/xh.png" align="absmiddle"></img>
					<img src="<%=request.getContextPath()%>/web/images/form_icon_1.gif" style="cursor:hand; vertical-align: middle;" onclick="selectshebei('epApplicableequipment')" />	
  			  </td>
  			  <td align="right">适用设备编号：</td>
  			  <td align="left">
  			    <input  type="text" readonly  id="epApplicableequipmentid" maxlength="50" name="epApplicableequipmentid" value="${epApplicableequipmentid}"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  />
  			  	
  			  </td>
  			 
  			  </tr>
  			   <tr>
  			  <td align="right">存放地点：</td>
  			  <td align="left">
  			    <input  type="text"  id="epStoragelocation" maxlength="50" name="epStoragelocation"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			   
  			   <td align="right">计量单位：</td>
  			  <td align="left">
  			    <input  type="text"  id="epMeasurementunit" maxlength="50" name="epMeasurementunit"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  </tr>
  		       <tr>
  		       <td align="right">设置库存提醒：</td>
  			   <td align="left" >
  			  	 <select  class='fselect'  id="epStockstate" maxlength="50" name="epStockstate"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  />
  			    <option value="是">是</option>
                <option value="否">否</option>
  			    </select>
  			  </td>
  			  <td align="right">备注：</td>
  			  <td align="left" >
  			    <input  type="text"  id="epRemark" maxlength="50" name="epRemark"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  />
  			  	
  			  </td>
    
  			  </tr> 	
  			  	 			
		</table>
		<table width="100%" border="0" align="center" class="formTableNew">
		  <tr>
			<td align="center">
		    	<input type="button" id="closeBtn" value="关闭" class="form_bt_grey" />
		    	<input id="saveBtn" type="button" value="保存"  class="form_bt_orange" />
		    </td>
		  </tr>
		</table>
	<!--表单结束-->
	</form>
  </body>
</html>
